package com.corx.network.config;

import com.corx.network.core.manager.StorageManager;
import com.corx.network.core.storage.Storage;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author gx
 * @version 1.0.0
 */
@Configuration
public class StorageManagerAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public StorageManager messageStorageManager(List<Storage> storages) {
        StorageManager manager = new StorageManager();
        if (storages != null) {
            storages.forEach(manager::registerStorage);
        }
        return manager;
    }

}
